<template>
	<view class="content">
		<view class="search-box flexWrap">
			<input placeholder="请输入关键词" placeholder-class="placeholderClass" v-model="keywords"/>
			<image src="../../static/shop/search-icon.png" class="search-icon" @tap="getList()"></image>
		</view>
		<view class="shop-box">
			<view class="shop-cont flexWrap">
				<view class="shop-item" v-for="(item,index) in shopList" :key='index' @tap="goPage('/pages/shop/shopDetails?goodsId='+item.id)">
					<view class="shop-img">
						<image :src="item.image"></image>
					</view>
					<view class="shop-name">{{item.title}}</view>
					<view class="price-box">
						<text>¥{{item.price||'--'}}</text>
						<text class="old-price">原价¥{{item.marketprice||'--'}}</text>
					</view>
				</view>
				<view class="empty-box" v-if="shopList.length==0">
					<image src="https://static.mo-yu.vip/wechat/images/orderEmpty.png"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				categoryId:"",
				shopList:[],
				keywords:""
			};
		},
		onLoad(ops) {
			this.categoryId=ops.categoryId
			this.getList();
		},
		methods:{
			getList(){
				this.$request.get(this.$api.categoryList, {
					id:this.categoryId,
					keywords:this.keywords
				}, {
					token:true
				}).then(res => {
					if (res.code==1) {
						let {data}=res
						this.shopList=data.data
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 30upx;
	}
	.search-box{
		height: 80rpx;
		background: #312F80;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		border: 2rpx solid #312F80;
		padding: 0 28upx;
		input{
			flex: 1;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #26BCFD;
		}
		.placeholderClass{
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #26BCFD;
		}
		.search-icon{
			width: 40upx;
			height: 40upx;
		}
	}
	.shop-box{
		margin-top: 48upx;
		.shop-cont{
			margin-top: 32upx;
			flex-wrap: wrap;
			.shop-item{
				margin-bottom: 40upx;
				width: 48%;
				.shop-img{
					width: 100%;
					height: 324rpx;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					overflow: hidden;
				}
				.shop-name{
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #82819B;
					margin-top: 24upx;
				}
				.price-box {
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					color: #26BCFD;
				
					.old-price {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #82819B;
						margin-left: 18upx;
						text-decoration: line-through;
					}
				}
			}
		}
	}
</style>
